
		* Figure 1
		* School Finance Reforms and District Resources: Event Study Estimates


		clear all
		use "C:\Users\EAsker\Desktop\ABR\data\finance_all_final.dta"
		
		* Merging finance data with individual-level survey data.
		
		merge 1:m ncesid using "C:\Users\EAsker\Desktop\ABR\data\indv_data_all.dta"
		
		/* Dropped districts do not exist in both individual-level 
		survey and finance data.*/
		
		drop if _merge~=3
	    drop _merge
		
		keep stfips ncesid rtexp_pp* rcexp_pp* rtrev_pp* rev_pp* dpblack80 ///
		dpurban80 dpcol80 dmedinc80 region  qrdinc80_b qr80_1 qr80_2 qr80_3 qr80_4
	
	/* To observe each district once every year, we dropped duplicates. 
	In this way, we obtained all districts where we have individuals studied.*/
	
    	duplicates drop ncesid stfips, force
	    reshape long rtexp_pp rcexp_pp rtrev_pp rev_pp,i(ncesid stfips) j(year)
		
		merge m:1 stfips using "C:\Users\EAsker\Desktop\ABR\data\finance_events.dta" 

	drop if _merge~=3
	drop _merge
	
	gen yrs_since=year-CSFR_year_BJH
	gen treat=1 if yrs_since~=.
	recode treat .=0
	replace yrs_since=0 if yrs_since==.

	gen tm6=1 if yrs_since<=-6 & yrs_since~=.
	recode tm6 .=0
	gen tm5=1 if yrs_since==-5
	recode tm5 .=0
	gen tm4=1 if yrs_since==-4
	recode tm4 .=0
	gen tm3=1 if yrs_since==-3
	recode tm3 .=0
	gen tm2=1 if yrs_since==-2
	recode tm2 .=0
	gen tm1=1 if yrs_since==-1
	recode tm1 .=0
	gen tp0=1 if yrs_since==0
	recode tp0 .=0
	gen tp1=1 if yrs_since==1
	recode tp1 .=0
	gen tp2=1 if yrs_since==2
	recode tp2 .=0
	gen tp3=1 if yrs_since==3
	recode tp3 .=0
	gen tp4=1 if yrs_since==4
	recode tp4 .=0
	gen tp5=1 if yrs_since==5
	recode tp5 .=0
	gen tp6=1 if yrs_since==6
	recode tp6 .=0
	gen tp7=1 if yrs_since==7
	recode tp7 .=0
	gen tp8=1 if yrs_since==8
	recode tp8 .=0
	gen tp9=1 if yrs_since==9
	recode tp9 .=0
	gen tp10=1 if yrs_since>=10 & yrs_since~=.
	recode tp10 .=0
	
	gen state_yr = stfips*year
	gen all = 1
	
	gen trend=year-1987
	
	gen black_trend=dpblack80*trend
	gen urban_trend=dpurban80*trend
	gen col_trend= dpcol80*trend
	gen inc_trend=dmedinc80*trend
	
	***********************************
	* State Aid for Quartile 1 and 4
	***********************************	
	
	*Q1
	
	foreach q in qr80_1    {
	preserve
	reghdfe rev_pp tm6 tm5 tm4 tm3 tm2 tp0 tp1 tp2 tp3 tp4 tp5 tp6 tp7 tp8 ///
	tp9 tp10 black_trend urban_trend col_trend inc_trend if `q'==1 , ///
	absorb(ncesid region#year) cluster(ncesid state_yr)

	foreach x in tm6 tm5 tm4 tm3 tm2 tp0 tp1 tp2 tp3 tp4 tp5 tp6 tp7 tp8 tp9 tp10 {
		foreach i in 6 5 4 3 2  {
			if "`x'"=="tm`i'" { 
			local y="m`i'" 
			}
		}
		forvalues i=0/10 {
			if "`x'"=="tp`i'" { 
			local y="p`i'" 
			}
		}
		
		gen b_`y' = _b[t`y']
		gen u_`y' = _b[t`y'] + ( _se[t`y'] * 1.96 )
		gen d_`y' = _b[t`y'] - ( _se[t`y'] * 1.96 )
	}
		
	*KEEP ONLY THE REGRESSION COEFFICIENTS AND CONFIDENCE INTERVALS;
	keep b_* u_* d_*

	*COLLAPSE DOWN TO ONE OBS PER REGRESSOR;
	collapse b_* u_* d_*
	
	*CREATE BETA AND CI'S AT MINUS ONE THAT ARE ALL ZERO;
	foreach x in b d u {
		gen `x'_m1 = 0
	}
	
	order ?_m6 ?_m5 ?_m4 ?_m3 ?_m2 ?_m1 ?_p0 ?_p1 ?_p2 ?_p3 ?_p4 ///
	?_p5 ?_p6 ?_p7 ?_p8 ?_p9 ?_p10
		
	/*CREATE THREE DATASETS, ONE W/THE COEFFICIENTS, ONE W/EACH CI. FOR EACH 
	DATASET, SWITH THE VARS INTO OBS, SO THAT EACH REGRESSOR BECOMES AN OBS, 
	WHICH MAKES SENSE BECAUSE EACH REGRESSOR REPRESENTS THE TREATMENT EFFECT 
	FROM A GIVEN RELATIVE YEAR. AND CREATE A NEW YEAR VARIABLE BASED OFF 
	THE NUMBER OF EACH OBSERVATION; */
	
	tempfile temp_bud
	save "`temp_bud'", replace

	/*NOTE - b stands for beta, u stands for up, d stands for down, 
	so I create a dataset for each; */
	
	keep b_*
	xpose, clear
	rename v1 beta
	local i = 1
	gen relative_year = .
	forvalues z=1/17 {
		replace relative_year = -7 + `i' if _n==`z'
		local i = `i'+1
	}
	tempfile temp_b
	save "`temp_b'"
		
	use "`temp_bud'", clear
	keep u_*
	xpose, clear
	rename v1 upper_ci
	local i = 1
	gen relative_year = .
	forvalues z=1/17 {
		replace relative_year = -7 + `i' if _n==`z'
		local i = `i'+1
	}
	tempfile temp_u
	save "`temp_u'"
		
	use "`temp_bud'", clear
	keep d_*
	xpose, clear
	rename v1 lower_ci
	local i = 1
	gen relative_year = .
	forvalues z=1/17 {
		replace relative_year = -7 + `i' if _n==`z'
		local i = `i'+1
	}
	tempfile temp_d
	save "`temp_d'"    
   
	use "`temp_b'", clear
	mmerge relative_year using "`temp_u'", type(1:1)
	mmerge relative_year using "`temp_d'", type(1:1)
	list

	*PLOT EVENT STUDY PICTURE
	twoway (line beta relative_year, lcolor(black) lpattern(solid)) ///
	(line upper_ci relative_year, lcolor(gray) lpattern(dash)) ///
	(line lower_ci relative_year, lcolor(gray) lpattern(dash)), ///
	legend(order(1 2) label(1 "Point Estimate") label(2 "95% Confidence Interval")) ///
	xtitle(Years Relative to Reform) xlabel(-6(2)10) xtick(-6(1)10) ///
	ytitle(2015 Dollars) ylabel(-500(500)2000) ytick(-500(250)2000) ///
	graphregion(color(white)) bgcolor(white) yline(0, lcolor(black) ///
	lstyle(shortdash_dot)) xline(-1, lcolor(black) lstyle(shortdash_dot)) 

	graph export "C:\Users\EAsker\Desktop\ABR\output\figures\fig_1_state_aid_q1.jpg", replace
	
	restore
}

	*Q4
	
	foreach q in qr80_4    {
	preserve
	reghdfe rev_pp tm6 tm5 tm4 tm3 tm2 tp0 tp1 tp2 tp3 tp4 tp5 tp6 tp7 tp8 ///
	tp9 tp10 black_trend urban_trend col_trend inc_trend if `q'==1 , ///
	absorb(ncesid region#year) cluster(ncesid state_yr)

	foreach x in tm6 tm5 tm4 tm3 tm2 tp0 tp1 tp2 tp3 tp4 tp5 tp6 tp7 tp8 tp9 tp10 {
		foreach i in 6 5 4 3 2  {
			if "`x'"=="tm`i'" { 
			local y="m`i'" 
			}
		}
		forvalues i=0/10 {
			if "`x'"=="tp`i'" { 
			local y="p`i'" 
			}
		}
		
		gen b_`y' = _b[t`y']
		gen u_`y' = _b[t`y'] + ( _se[t`y'] * 1.96 )
		gen d_`y' = _b[t`y'] - ( _se[t`y'] * 1.96 )
	}
		
	*KEEP ONLY THE REGRESSION COEFFICIENTS AND CONFIDENCE INTERVALS;
	keep b_* u_* d_*

	*COLLAPSE DOWN TO ONE OBS PER REGRESSOR;
	collapse b_* u_* d_*
	
	*CREATE BETA AND CI'S AT MINUS ONE THAT ARE ALL ZERO;
	foreach x in b d u {
		gen `x'_m1 = 0
	}
	
	order ?_m6 ?_m5 ?_m4 ?_m3 ?_m2 ?_m1 ?_p0 ?_p1 ?_p2 ?_p3 ?_p4 ///
	?_p5 ?_p6 ?_p7 ?_p8 ?_p9 ?_p10
		
	/*CREATE THREE DATASETS, ONE W/THE COEFFICIENTS, ONE W/EACH CI. FOR EACH 
	DATASET, SWITH THE VARS INTO OBS, SO THAT EACH REGRESSOR BECOMES AN OBS, 
	WHICH MAKES SENSE BECAUSE EACH REGRESSOR REPRESENTS THE TREATMENT EFFECT 
	FROM A GIVEN RELATIVE YEAR. AND CREATE A NEW YEAR VARIABLE BASED OFF 
	THE NUMBER OF EACH OBSERVATION; */
	
	tempfile temp_bud
	save "`temp_bud'", replace

	/*NOTE - b stands for beta, u stands for up, d stands for down, 
	so I create a dataset for each; */
	
	keep b_*
	xpose, clear
	rename v1 beta
	local i = 1
	gen relative_year = .
	forvalues z=1/17 {
		replace relative_year = -7 + `i' if _n==`z'
		local i = `i'+1
	}
	tempfile temp_b
	save "`temp_b'"
		
	use "`temp_bud'", clear
	keep u_*
	xpose, clear
	rename v1 upper_ci
	local i = 1
	gen relative_year = .
	forvalues z=1/17 {
		replace relative_year = -7 + `i' if _n==`z'
		local i = `i'+1
	}
	tempfile temp_u
	save "`temp_u'"
		
	use "`temp_bud'", clear
	keep d_*
	xpose, clear
	rename v1 lower_ci
	local i = 1
	gen relative_year = .
	forvalues z=1/17 {
		replace relative_year = -7 + `i' if _n==`z'
		local i = `i'+1
	}
	tempfile temp_d
	save "`temp_d'"    
   
	use "`temp_b'", clear
	mmerge relative_year using "`temp_u'", type(1:1)
	mmerge relative_year using "`temp_d'", type(1:1)
	list

	*PLOT EVENT STUDY PICTURE
	twoway (line beta relative_year, lcolor(black) lpattern(solid)) ///
	(line upper_ci relative_year, lcolor(gray) lpattern(dash)) ///
	(line lower_ci relative_year, lcolor(gray) lpattern(dash)), ///
	legend(order(1 2) label(1 "Point Estimate") label(2 "95% Confidence Interval")) ///
	xtitle(Years Relative to Reform) xlabel(-6(2)10) xtick(-6(1)10) ///
	ytitle(2015 Dollars) ylabel(-500(500)2000) ytick(-500(250)2000) ///
	graphregion(color(white)) bgcolor(white) yline(0, lcolor(black) ///
	lstyle(shortdash_dot)) xline(-1, lcolor(black) lstyle(shortdash_dot)) 

	graph export "C:\Users\EAsker\Desktop\ABR\output\figures\fig_1_state_aid_q4.jpg", replace
	
	restore
}
	
	*****************************************
	* Total Expenditure for Quartile 1 and 4
	*****************************************	
	
	*Q1
	
	foreach q in qr80_1    {
	preserve
	reghdfe rtexp_pp tm6 tm5 tm4 tm3 tm2 tp0 tp1 tp2 tp3 tp4 tp5 tp6 tp7 tp8 ///
	tp9 tp10 black_trend urban_trend col_trend inc_trend if `q'==1 , ///
	absorb(ncesid region#year) cluster(ncesid state_yr)

	foreach x in tm6 tm5 tm4 tm3 tm2 tp0 tp1 tp2 tp3 tp4 tp5 tp6 tp7 tp8 tp9 tp10 {
		foreach i in 6 5 4 3 2  {
			if "`x'"=="tm`i'" { 
			local y="m`i'" 
			}
		}
		forvalues i=0/10 {
			if "`x'"=="tp`i'" { 
			local y="p`i'" 
			}
		}
		
		gen b_`y' = _b[t`y']
		gen u_`y' = _b[t`y'] + ( _se[t`y'] * 1.96 )
		gen d_`y' = _b[t`y'] - ( _se[t`y'] * 1.96 )
	}
		
	*KEEP ONLY THE REGRESSION COEFFICIENTS AND CONFIDENCE INTERVALS;
	keep b_* u_* d_*

	*COLLAPSE DOWN TO ONE OBS PER REGRESSOR;
	collapse b_* u_* d_*
	
	*CREATE BETA AND CI'S AT MINUS ONE THAT ARE ALL ZERO;
	foreach x in b d u {
		gen `x'_m1 = 0
	}
	
	order ?_m6 ?_m5 ?_m4 ?_m3 ?_m2 ?_m1 ?_p0 ?_p1 ?_p2 ?_p3 ?_p4 ///
	?_p5 ?_p6 ?_p7 ?_p8 ?_p9 ?_p10
		
	/*CREATE THREE DATASETS, ONE W/THE COEFFICIENTS, ONE W/EACH CI. FOR EACH 
	DATASET, SWITH THE VARS INTO OBS, SO THAT EACH REGRESSOR BECOMES AN OBS, 
	WHICH MAKES SENSE BECAUSE EACH REGRESSOR REPRESENTS THE TREATMENT EFFECT 
	FROM A GIVEN RELATIVE YEAR. AND CREATE A NEW YEAR VARIABLE BASED OFF 
	THE NUMBER OF EACH OBSERVATION; */
	
	tempfile temp_bud
	save "`temp_bud'", replace

	/*NOTE - b stands for beta, u stands for up, d stands for down, 
	so I create a dataset for each; */
	
	keep b_*
	xpose, clear
	rename v1 beta
	local i = 1
	gen relative_year = .
	forvalues z=1/17 {
		replace relative_year = -7 + `i' if _n==`z'
		local i = `i'+1
	}
	tempfile temp_b
	save "`temp_b'"
		
	use "`temp_bud'", clear
	keep u_*
	xpose, clear
	rename v1 upper_ci
	local i = 1
	gen relative_year = .
	forvalues z=1/17 {
		replace relative_year = -7 + `i' if _n==`z'
		local i = `i'+1
	}
	tempfile temp_u
	save "`temp_u'"
		
	use "`temp_bud'", clear
	keep d_*
	xpose, clear
	rename v1 lower_ci
	local i = 1
	gen relative_year = .
	forvalues z=1/17 {
		replace relative_year = -7 + `i' if _n==`z'
		local i = `i'+1
	}
	tempfile temp_d
	save "`temp_d'"    
   
	use "`temp_b'", clear
	mmerge relative_year using "`temp_u'", type(1:1)
	mmerge relative_year using "`temp_d'", type(1:1)
	list

	*PLOT EVENT STUDY PICTURE
	twoway (line beta relative_year, lcolor(black) lpattern(solid)) ///
	(line upper_ci relative_year, lcolor(gray) lpattern(dash)) ///
	(line lower_ci relative_year, lcolor(gray) lpattern(dash)), ///
	legend(order(1 2) label(1 "Point Estimate") label(2 "95% Confidence Interval")) ///
	xtitle(Years Relative to Reform) xlabel(-6(2)10) xtick(-6(1)10) ///
	ytitle(2015 Dollars) ylabel(-500(500)2000) ytick(-500(250)2000) ///
	graphregion(color(white)) bgcolor(white) yline(0, lcolor(black) ///
	lstyle(shortdash_dot)) xline(-1, lcolor(black) lstyle(shortdash_dot)) 

	graph export "C:\Users\EAsker\Desktop\ABR\output\figures\fig_1_tot_exp_q1.jpg", replace
	
	restore
}

	*Q4
	
	foreach q in qr80_4    {
	preserve
	reghdfe rtexp_pp tm6 tm5 tm4 tm3 tm2 tp0 tp1 tp2 tp3 tp4 tp5 tp6 tp7 tp8 ///
	tp9 tp10 black_trend urban_trend col_trend inc_trend if `q'==1 , ///
	absorb(ncesid region#year) cluster(ncesid state_yr)

	foreach x in tm6 tm5 tm4 tm3 tm2 tp0 tp1 tp2 tp3 tp4 tp5 tp6 tp7 tp8 tp9 tp10 {
		foreach i in 6 5 4 3 2  {
			if "`x'"=="tm`i'" { 
			local y="m`i'" 
			}
		}
		forvalues i=0/10 {
			if "`x'"=="tp`i'" { 
			local y="p`i'" 
			}
		}
		
		gen b_`y' = _b[t`y']
		gen u_`y' = _b[t`y'] + ( _se[t`y'] * 1.96 )
		gen d_`y' = _b[t`y'] - ( _se[t`y'] * 1.96 )
	}
		
	*KEEP ONLY THE REGRESSION COEFFICIENTS AND CONFIDENCE INTERVALS;
	keep b_* u_* d_*

	*COLLAPSE DOWN TO ONE OBS PER REGRESSOR;
	collapse b_* u_* d_*
	
	*CREATE BETA AND CI'S AT MINUS ONE THAT ARE ALL ZERO;
	foreach x in b d u {
		gen `x'_m1 = 0
	}
	
	order ?_m6 ?_m5 ?_m4 ?_m3 ?_m2 ?_m1 ?_p0 ?_p1 ?_p2 ?_p3 ?_p4 ///
	?_p5 ?_p6 ?_p7 ?_p8 ?_p9 ?_p10
		
	/*CREATE THREE DATASETS, ONE W/THE COEFFICIENTS, ONE W/EACH CI. FOR EACH 
	DATASET, SWITH THE VARS INTO OBS, SO THAT EACH REGRESSOR BECOMES AN OBS, 
	WHICH MAKES SENSE BECAUSE EACH REGRESSOR REPRESENTS THE TREATMENT EFFECT 
	FROM A GIVEN RELATIVE YEAR. AND CREATE A NEW YEAR VARIABLE BASED OFF 
	THE NUMBER OF EACH OBSERVATION; */
	
	tempfile temp_bud
	save "`temp_bud'", replace

	/*NOTE - b stands for beta, u stands for up, d stands for down, 
	so I create a dataset for each; */
	
	keep b_*
	xpose, clear
	rename v1 beta
	local i = 1
	gen relative_year = .
	forvalues z=1/17 {
		replace relative_year = -7 + `i' if _n==`z'
		local i = `i'+1
	}
	tempfile temp_b
	save "`temp_b'"
		
	use "`temp_bud'", clear
	keep u_*
	xpose, clear
	rename v1 upper_ci
	local i = 1
	gen relative_year = .
	forvalues z=1/17 {
		replace relative_year = -7 + `i' if _n==`z'
		local i = `i'+1
	}
	tempfile temp_u
	save "`temp_u'"
		
	use "`temp_bud'", clear
	keep d_*
	xpose, clear
	rename v1 lower_ci
	local i = 1
	gen relative_year = .
	forvalues z=1/17 {
		replace relative_year = -7 + `i' if _n==`z'
		local i = `i'+1
	}
	tempfile temp_d
	save "`temp_d'"    
   
	use "`temp_b'", clear
	mmerge relative_year using "`temp_u'", type(1:1)
	mmerge relative_year using "`temp_d'", type(1:1)
	list

	*PLOT EVENT STUDY PICTURE
	twoway (line beta relative_year, lcolor(black) lpattern(solid)) ///
	(line upper_ci relative_year, lcolor(gray) lpattern(dash)) ///
	(line lower_ci relative_year, lcolor(gray) lpattern(dash)), ///
	legend(order(1 2) label(1 "Point Estimate") label(2 "95% Confidence Interval")) ///
	xtitle(Years Relative to Reform) xlabel(-6(2)10) xtick(-6(1)10) ///
	ytitle(2015 Dollars) ylabel(-500(500)2000) ytick(-500(250)2000) ///
	graphregion(color(white)) bgcolor(white) yline(0, lcolor(black) ///
	lstyle(shortdash_dot)) xline(-1, lcolor(black) lstyle(shortdash_dot)) 

	graph export "C:\Users\EAsker\Desktop\ABR\output\figures\fig_1_tot_exp_q4.jpg", replace
	
	restore
}

	******************************************
	* Current Expenditure for Quartile 1 and 4
	******************************************	
	
	*Q1
	
	foreach q in qr80_1    {
	preserve
	reghdfe rcexp_pp tm6 tm5 tm4 tm3 tm2 tp0 tp1 tp2 tp3 tp4 tp5 tp6 tp7 tp8 ///
	tp9 tp10 black_trend urban_trend col_trend inc_trend if `q'==1 , ///
	absorb(ncesid region#year) cluster(ncesid state_yr)

	foreach x in tm6 tm5 tm4 tm3 tm2 tp0 tp1 tp2 tp3 tp4 tp5 tp6 tp7 tp8 tp9 tp10 {
		foreach i in 6 5 4 3 2  {
			if "`x'"=="tm`i'" { 
			local y="m`i'" 
			}
		}
		forvalues i=0/10 {
			if "`x'"=="tp`i'" { 
			local y="p`i'" 
			}
		}
		
		gen b_`y' = _b[t`y']
		gen u_`y' = _b[t`y'] + ( _se[t`y'] * 1.96 )
		gen d_`y' = _b[t`y'] - ( _se[t`y'] * 1.96 )
	}
		
	*KEEP ONLY THE REGRESSION COEFFICIENTS AND CONFIDENCE INTERVALS;
	keep b_* u_* d_*

	*COLLAPSE DOWN TO ONE OBS PER REGRESSOR;
	collapse b_* u_* d_*
	
	*CREATE BETA AND CI'S AT MINUS ONE THAT ARE ALL ZERO;
	foreach x in b d u {
		gen `x'_m1 = 0
	}
	
	order ?_m6 ?_m5 ?_m4 ?_m3 ?_m2 ?_m1 ?_p0 ?_p1 ?_p2 ?_p3 ?_p4 ///
	?_p5 ?_p6 ?_p7 ?_p8 ?_p9 ?_p10
		
	/*CREATE THREE DATASETS, ONE W/THE COEFFICIENTS, ONE W/EACH CI. FOR EACH 
	DATASET, SWITH THE VARS INTO OBS, SO THAT EACH REGRESSOR BECOMES AN OBS, 
	WHICH MAKES SENSE BECAUSE EACH REGRESSOR REPRESENTS THE TREATMENT EFFECT 
	FROM A GIVEN RELATIVE YEAR. AND CREATE A NEW YEAR VARIABLE BASED OFF 
	THE NUMBER OF EACH OBSERVATION; */
	
	tempfile temp_bud
	save "`temp_bud'", replace

	/*NOTE - b stands for beta, u stands for up, d stands for down, 
	so I create a dataset for each; */
	
	keep b_*
	xpose, clear
	rename v1 beta
	local i = 1
	gen relative_year = .
	forvalues z=1/17 {
		replace relative_year = -7 + `i' if _n==`z'
		local i = `i'+1
	}
	tempfile temp_b
	save "`temp_b'"
		
	use "`temp_bud'", clear
	keep u_*
	xpose, clear
	rename v1 upper_ci
	local i = 1
	gen relative_year = .
	forvalues z=1/17 {
		replace relative_year = -7 + `i' if _n==`z'
		local i = `i'+1
	}
	tempfile temp_u
	save "`temp_u'"
		
	use "`temp_bud'", clear
	keep d_*
	xpose, clear
	rename v1 lower_ci
	local i = 1
	gen relative_year = .
	forvalues z=1/17 {
		replace relative_year = -7 + `i' if _n==`z'
		local i = `i'+1
	}
	tempfile temp_d
	save "`temp_d'"    
   
	use "`temp_b'", clear
	mmerge relative_year using "`temp_u'", type(1:1)
	mmerge relative_year using "`temp_d'", type(1:1)
	list

	*PLOT EVENT STUDY PICTURE
	twoway (line beta relative_year, lcolor(black) lpattern(solid)) ///
	(line upper_ci relative_year, lcolor(gray) lpattern(dash)) ///
	(line lower_ci relative_year, lcolor(gray) lpattern(dash)), ///
	legend(order(1 2) label(1 "Point Estimate") label(2 "95% Confidence Interval")) ///
	xtitle(Years Relative to Reform) xlabel(-6(2)10) xtick(-6(1)10) ///
	ytitle(2015 Dollars) ylabel(-500(500)2000) ytick(-500(250)2000) ///
	graphregion(color(white)) bgcolor(white) yline(0, lcolor(black) ///
	lstyle(shortdash_dot)) xline(-1, lcolor(black) lstyle(shortdash_dot)) 

	graph export "C:\Users\EAsker\Desktop\ABR\output\figures\fig_1_cur_exp_q1.jpg", replace
	
	restore
}
	
	*Q4
	
	foreach q in qr80_4    {
	preserve
	reghdfe rcexp_pp tm6 tm5 tm4 tm3 tm2 tp0 tp1 tp2 tp3 tp4 tp5 tp6 tp7 tp8 ///
	tp9 tp10 black_trend urban_trend col_trend inc_trend if `q'==1 , ///
	absorb(ncesid region#year) cluster(ncesid state_yr)

	foreach x in tm6 tm5 tm4 tm3 tm2 tp0 tp1 tp2 tp3 tp4 tp5 tp6 tp7 tp8 tp9 tp10 {
		foreach i in 6 5 4 3 2  {
			if "`x'"=="tm`i'" { 
			local y="m`i'" 
			}
		}
		forvalues i=0/10 {
			if "`x'"=="tp`i'" { 
			local y="p`i'" 
			}
		}
		
		gen b_`y' = _b[t`y']
		gen u_`y' = _b[t`y'] + ( _se[t`y'] * 1.96 )
		gen d_`y' = _b[t`y'] - ( _se[t`y'] * 1.96 )
	}
		
	*KEEP ONLY THE REGRESSION COEFFICIENTS AND CONFIDENCE INTERVALS;
	keep b_* u_* d_*

	*COLLAPSE DOWN TO ONE OBS PER REGRESSOR;
	collapse b_* u_* d_*
	
	*CREATE BETA AND CI'S AT MINUS ONE THAT ARE ALL ZERO;
	foreach x in b d u {
		gen `x'_m1 = 0
	}
	
	order ?_m6 ?_m5 ?_m4 ?_m3 ?_m2 ?_m1 ?_p0 ?_p1 ?_p2 ?_p3 ?_p4 ///
	?_p5 ?_p6 ?_p7 ?_p8 ?_p9 ?_p10
		
	/*CREATE THREE DATASETS, ONE W/THE COEFFICIENTS, ONE W/EACH CI. FOR EACH 
	DATASET, SWITH THE VARS INTO OBS, SO THAT EACH REGRESSOR BECOMES AN OBS, 
	WHICH MAKES SENSE BECAUSE EACH REGRESSOR REPRESENTS THE TREATMENT EFFECT 
	FROM A GIVEN RELATIVE YEAR. AND CREATE A NEW YEAR VARIABLE BASED OFF 
	THE NUMBER OF EACH OBSERVATION; */
	
	tempfile temp_bud
	save "`temp_bud'", replace

	/*NOTE - b stands for beta, u stands for up, d stands for down, 
	so I create a dataset for each; */
	
	keep b_*
	xpose, clear
	rename v1 beta
	local i = 1
	gen relative_year = .
	forvalues z=1/17 {
		replace relative_year = -7 + `i' if _n==`z'
		local i = `i'+1
	}
	tempfile temp_b
	save "`temp_b'"
		
	use "`temp_bud'", clear
	keep u_*
	xpose, clear
	rename v1 upper_ci
	local i = 1
	gen relative_year = .
	forvalues z=1/17 {
		replace relative_year = -7 + `i' if _n==`z'
		local i = `i'+1
	}
	tempfile temp_u
	save "`temp_u'"
		
	use "`temp_bud'", clear
	keep d_*
	xpose, clear
	rename v1 lower_ci
	local i = 1
	gen relative_year = .
	forvalues z=1/17 {
		replace relative_year = -7 + `i' if _n==`z'
		local i = `i'+1
	}
	tempfile temp_d
	save "`temp_d'"    
   
	use "`temp_b'", clear
	mmerge relative_year using "`temp_u'", type(1:1)
	mmerge relative_year using "`temp_d'", type(1:1)
	list

	*PLOT EVENT STUDY PICTURE
	twoway (line beta relative_year, lcolor(black) lpattern(solid)) ///
	(line upper_ci relative_year, lcolor(gray) lpattern(dash)) ///
	(line lower_ci relative_year, lcolor(gray) lpattern(dash)), ///
	legend(order(1 2) label(1 "Point Estimate") label(2 "95% Confidence Interval")) ///
	xtitle(Years Relative to Reform) xlabel(-6(2)10) xtick(-6(1)10) ///
	ytitle(2015 Dollars) ylabel(-500(500)2000) ytick(-500(250)2000) ///
	graphregion(color(white)) bgcolor(white) yline(0, lcolor(black) ///
	lstyle(shortdash_dot)) xline(-1, lcolor(black) lstyle(shortdash_dot)) 

	graph export "C:\Users\EAsker\Desktop\ABR\output\figures\fig_1_cur_exp_q4.jpg", replace
	
	restore
}



